/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package SimpleControl;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author fherher
 */
public class SimpleTableModel extends AbstractTableModel {
    private String []header = new String []{};
    private ArrayList data = new ArrayList();
    
    /*public SimpleTableModel()
    {
        
    }*/
    
    public int getRowCount() {
        return header.length;
    }

    public int getColumnCount() {
        return data.size();
    }
    
    public Object getValueAt(int rowIndex, int columnIndex) {
        return ((Object[])data.get(rowIndex))[columnIndex];
    }
    
    @Override
    public String getColumnName(int column)
    {
        return header[column];
    }
    
    @Override
    public boolean isCellEditable(int row, int col) {
        return false;
    }

    public String[] getHeader() {
        return header;
    }

    public void setHeader(String[] header) {
        this.header = header;
    }

    public Object[][] getData() {
        return (Object[][])data.toArray();
    }

    public void setData(Object[][] data) {
        this.data.clear();
        for (int i = 0; i < data.length; i++)
            this.data.add(data[i]);
    }

    void removeRow(int i) {
        this.data.remove(i);
    }
    
    void addRow(Object []row)
    {
        this.data.add(row);
    }
}
